package entry;

import java.io.File;
import java.util.List;

public class User {
    private int userId;
    private String username;
    private String password;
    private String photo;
    private String github;
    private List<User> fans;

    public List<User> getFans() {
        return fans;
    }

    public void setFans(List<User> fans) {
        this.fans = fans;
    }

    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }

    public String getPhoto() {
        return photo;
    }

    public void setPhoto(String photo) {
        this.photo = photo;
    }

    public String getGithub() {
        return github;
    }

    public void setGithub(String github) {
        this.github = github;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }


    @Override
    public String toString() {
        return "User{" +
                "userId=" + userId +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", photo='" + photo + '\'' +
                ", github='" + github + '\'' +
                '}';
    }

    public static void deletePhoto(String username, String path){
        File root = new File(path);
        // 来到 image文件夹下, 遍历文件
        for (File file : root.listFiles()) {
            String name = file.getName().split("_")[0];
            if (name.equals(username)){
                file.delete();
            }
        }
    }
}
